var Adv_skd=require("./Adv_skd")

var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2pvzChannel = require("pvzChannel");
var $2BundleManager = require("BundleManager");
var $2PlantMgr = require("PlantMgr");
var $2SceneStage = require("SceneStage");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_AdReviveUI = /* */function (_cc$Component2) {
  babel_inherits(d, _cc$Component2);
  var _super2 = babel_createSuper(d);
  function d() {
    var _this3;
    babel_classCallCheck(this, d);
    _this3 = _super2.apply(this, arguments);
    _this3.bt1 = null;
    _this3.bt_heighLight = null;
    _this3.close = null;
    _this3.video = null;
    _this3.spine = null;
    _this3.plantId = -1;
    _this3.plantPos = null;
    _this3.row = -1;
    _this3.col = -1;
    return _this3;
  }
  babel_createClass(d, [{
    key: "onLoad",
    value: function onLoad() {
      var _this4 = this;
      this.bt1.on(cc.Node.EventType.TOUCH_END, function () {
        $2pvzChannel.pvzChannel.instance().showVideo({
          sucCall() {
            $2SceneStage.default.instance.revivePlant(_this4.plantId, _this4.plantPos, _this4.row, _this4.col);
            _this4.hide();
          },
          failCall() {},
          endCall() {}
        });
      }, this);
      this.close.on(cc.Node.EventType.TOUCH_END, function () {
        _this4.hide();
      }, this);
      cc.tween(this.bt_heighLight).repeatForever(cc.tween().to(.3, {
        scale: 1.2
      }).to(.3, {
        scale: 1
      })).start();
    }
  }, {
    key: "show",
    value: function show(e, t, a) {
       Adv_skd.default.instance.hideAllAdv();
                  Adv_skd.default.instance.showInterstitialAd();
                  Adv_skd.default.instance.showGridAdRight();
                  Adv_skd.default.instance.showGridAdLeft();

      this.plantId = e.id;
      this.plantPos = a;
      this.row = e.row;
      this.col = e.col;
      this.node.parent = t;
      this.spine.skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "plant/" + $2PlantMgr.default.instance().getPlant(this.plantId).dragonName + "/" + $2PlantMgr.default.instance().getPlant(this.plantId).dragonName, sp.SkeletonData);
      e.skinName && this.spine.setSkin(e.skinName);
      this.spine.setAnimation(0, "daiji", true);
      $2SceneStage.default.instance.pause();
      $2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0 && $2pvzChannel.pvzChannel.instance().getCtrl("p4") && (this.video.active = false);
    }
  }, {
    key: "hide",
    value: function hide() {
      Adv_skd.default.instance.hideAllAdv();

      cc.Tween.stopAllByTarget(this.bt_heighLight);
      this.node.destroy();
      $2SceneStage.default.instance.resume();
    }
  }]);
  return d;
}(cc.Component);
cc__decorate([ccp_property(cc.Node)], def_AdReviveUI.prototype, "bt1", undefined);
cc__decorate([ccp_property(cc.Node)], def_AdReviveUI.prototype, "bt_heighLight", undefined);
cc__decorate([ccp_property(cc.Node)], def_AdReviveUI.prototype, "close", undefined);
cc__decorate([ccp_property(cc.Node)], def_AdReviveUI.prototype, "video", undefined);
cc__decorate([ccp_property(sp.Skeleton)], def_AdReviveUI.prototype, "spine", undefined);
def_AdReviveUI = cc__decorate([ccp_ccclass], def_AdReviveUI);
exports.default = def_AdReviveUI;